/*
 Navicat Premium Data Transfer

 Source Server         : 本地mysql
 Source Server Type    : MySQL
 Source Server Version : 50619
 Source Host           : localhost
 Source Database       : onlineCode

 Target Server Type    : MySQL
 Target Server Version : 50619
 File Encoding         : utf-8

 Date: 05/05/2018 00:18:46 AM
*/

SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
--  Table structure for `codeLog`
-- ----------------------------
DROP TABLE IF EXISTS `codeLog`;
CREATE TABLE `codeLog` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `modify_date` datetime DEFAULT NULL,
  `remark` varchar(500) DEFAULT NULL COMMENT '修改备注',
  PRIMARY KEY (`id`),
  KEY `code_id` (`code_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `codelog_ibfk_3` FOREIGN KEY (`code_id`) REFERENCES `codes` (`id`),
  CONSTRAINT `codelog_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `codeLog`
-- ----------------------------
BEGIN;
INSERT INTO `codeLog` VALUES ('1', '4', '2', '2018-04-25 11:38:03', '添加了一个main 方法'), ('2', '1', '3', '2018-04-25 18:52:21', '吐槽了一句'), ('3', '1', '2', '2018-04-26 14:27:24', '添加了一句吐槽的话'), ('4', '5', '2', '2018-04-26 16:26:08', '添加了一行测试代码');
COMMIT;

-- ----------------------------
--  Table structure for `codes`
-- ----------------------------
DROP TABLE IF EXISTS `codes`;
CREATE TABLE `codes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL COMMENT '创建人',
  `language_id` int(11) DEFAULT NULL COMMENT '代码语言',
  `code` text COMMENT '代码片段',
  `createDate` datetime DEFAULT NULL COMMENT '创建日期',
  `last_modify_user_id` int(11) DEFAULT NULL COMMENT '最后一次修改人编号',
  `last_modify_date` datetime DEFAULT NULL COMMENT '最后一次修改日期',
  `isPublic` int(11) DEFAULT NULL COMMENT '是否公开共享',
  `name` varchar(100) DEFAULT NULL COMMENT '代码片段名称',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `language_id` (`language_id`),
  KEY `language_id_2` (`language_id`),
  KEY `language_id_3` (`language_id`),
  CONSTRAINT `codes_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
  CONSTRAINT `codes_ibfk_2` FOREIGN KEY (`language_id`) REFERENCES `language` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `codes`
-- ----------------------------
BEGIN;
INSERT INTO `codes` VALUES ('1', '2', '2', 'JUST for test\r\n你测试法什么法啊\r\n那我也加一句话吧', '2018-04-24 14:33:29', '2', '2018-04-26 14:27:24', '1', '一个测试代码片段'), ('3', '3', '1', 'HaHa world', '2018-04-24 17:30:03', '2', '2018-04-24 17:30:13', '0', 'hello world'), ('4', '2', '3', 'public class Hello{\r\n	public static void main(String[] args){\r\n	\r\n	}\r\n}', '2018-04-25 09:46:25', '2', '2018-04-25 11:38:03', '0', 'Hello World 入门程序'), ('5', '4', '3', 'public class Test {\r\n	public static void main(String[] args) {\r\n		System.out.println(\"hello Java!\");\r\n		System.out.println(\"this is the second line\");\r\n		System.out.println(\"我添加了一行\");\r\n	}\r\n}\r\n', '2018-04-26 16:24:55', '2', '2018-04-26 16:26:08', '1', '');
COMMIT;

-- ----------------------------
--  Table structure for `language`
-- ----------------------------
DROP TABLE IF EXISTS `language`;
CREATE TABLE `language` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `browser` int(11) DEFAULT NULL COMMENT '是否可以直接浏览器运行',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `language`
-- ----------------------------
BEGIN;
INSERT INTO `language` VALUES ('1', 'HTML', '1'), ('2', 'JS', '1'), ('3', 'JAVA', '0'), ('4', 'CSS', '0'), ('5', 'PHP', '0'), ('6', 'PYTHON', '0');
COMMIT;

-- ----------------------------
--  Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) DEFAULT NULL,
  `password` varchar(50) DEFAULT NULL,
  `nickName` varchar(50) DEFAULT NULL,
  `createDate` datetime DEFAULT NULL,
  `lastLogin` datetime DEFAULT NULL,
  `online` int(4) DEFAULT NULL COMMENT '是否在线',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `user`
-- ----------------------------
BEGIN;
INSERT INTO `user` VALUES ('2', 'maomao', 'yaoyao', '毛毛', '2018-04-23 19:51:58', null, '0'), ('3', 'admin', 'admin', '超级', '2018-04-24 17:32:19', null, '0'), ('4', 'test', 'test', '测试用户', '2018-04-26 16:21:52', null, '0');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
